﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Client.ShopServiceReference;
using ServerApp;
using Server;

namespace Client
{
    public class OrdersModel : IOrdersModel
    {

        /// <summary>
        /// Gets the list of the orders views
        /// </summary>        
        /// <param name="page">Number of the page</param>        
        /// <param name="filter">Dictionary<OrderFilter.value,object></param>
        /// <param name="numberOnThePage">Number of the orders on the one page</param>
        /// <returns>list of the orderView</returns> 
        public List<OrderView> GetOrders(Dictionary<OrderFilter, object> filter, int page, int numberOfOrders)
        {
            return Service.Instance.GetOrderList(filter, page, numberOfOrders).ToList();
        }


        /// <summary>
        /// Gets the concrete order by its id
        /// </summary>
        /// <param name="id">Id of the order</param>
        /// <param name="language">Language</param>
        /// <returns>OrderFull value of the current order</returns>
        public Server.OrderFull GetOrder(long id, string language)
        {
            return Service.Instance.GetOrder(id, language);
        }


        /// <summary>
        /// Reserves the order (changes its status)
        /// </summary>
        /// <param name="orderId">order id</param>
        /// <param name="executorId">executor id</param>
        /// <returns>new OrderView value</returns>
        public OrderFull ReserveOrder(long orderId, long executorId)
        {
            return Service.Instance.ReserveOrder(orderId, executorId);
        }


        /// <summary>
        /// Closes the order 
        /// </summary>
        /// <param name="orderId">order id</param>
        /// <returns>new OrderView value</returns>
        public OrderFull CloseOrder(long orderId)
        {
            return Service.Instance.CloseOrder(orderId);
        }


        /// <summary>
        /// Cancel the order and unreserves all products of this order
        /// </summary>
        /// <param name="orderId">Id of the order</param>
        /// <returns>bool value</returns>
        public bool CancelOrder(long orderId)
        {
            return Service.Instance.CancelOrder(orderId);
        }
    }//class
}
